package nc.ui.arap.bastradisc.excelimport;

import java.util.List;

import javax.swing.JComponent;

import nc.itf.trade.excelimport.IImportableEditor;
import nc.ui.pub.beans.UIDialog;
import nc.ui.trade.excelimport.BillItemImportSetDlg;
import nc.ui.trade.excelimport.ExcelImporter;
import nc.ui.trade.excelimport.InputItem;
import nc.ui.uif2.excelimport.DefaultUIF2ImportableEditor;

public class BasTradiscExcelImporter extends ExcelImporter{

	@Override
	public boolean beforeExport(IImportableEditor editor) {
		String funcode = ((DefaultUIF2ImportableEditor)editor).getAppModel().getContext().getFuncInfo().getFuncode();
		
		boolean ret = false;
		JComponent parent = editor.getJComponent();
		setDlg(new BillItemImportSetDlg(parent, editor.getInputItems(),funcode,null,false));
		getDlg().setInputitemSeleStrategy(new BasTradiscSeleStrategy());
		getDlg().initialize();
		
		if (getDlg().showModal() == UIDialog.ID_OK) {
			List<InputItem> items = getDlg().getInputItems();
			if(items == null || items.size() == 0) {
				return false;
			}
			ret = getSaveExcelFile(parent) != null;
		}

		return ret;
	}
	
}
